package com.example.mqttclient;

import java.util.Map;

public class CarbonFootprintCalculator {
    // 碳排放因子 (kgCO2/kWh)
    private static final double ELECTRICITY_EMISSION_FACTOR = 0.583;

    // 修改方法签名，将long改为double
    public static double calculateDeviceEmission(double power, double durationHours) {
        double kWh = (power * durationHours) / 1000.0;
        return kWh * ELECTRICITY_EMISSION_FACTOR;
    }

    public static double calculateTotalEmission(Map<String, Double> deviceConsumptions) {
        double total = 0;
        for (Double consumption : deviceConsumptions.values()) {
            total += consumption * ELECTRICITY_EMISSION_FACTOR;
        }
        return total;
    }
}